﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls">

	<!-- BEGIN TreeViewToggleButton -->
	<Style x:Key="PlusMinusTreeViewToggleButton" TargetType="{x:Type Controls:SinacorTreeViewToggleButton}">
		<Setter Property="Width" Value="19"/>
		<Setter Property="Height" Value="17"/>

		<Setter Property="IsThreeState" Value="False"/>
		<Setter Property="ClickMode" Value="Press"/>
		<Setter Property="IsChecked" Value="{Binding IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeViewItem}}}" />
		<Setter Property="HasItems" Value="{Binding HasItems, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeViewItem}}}" />
		<Setter Property="Focusable" Value="False"/>

		<Setter Property="CollapsedStateTemplate">
			<Setter.Value>
				<DataTemplate>
					<Border Width="19" Height="13" Background="Transparent">
						<Border Width="9" Height="9" SnapsToDevicePixels="true" BorderBrush="{DynamicResource BrushTreeViewToggleButtonBorder}" BorderThickness="1" CornerRadius="1" Background="{DynamicResource BrushTreeViewToggleButtonBackground}">
							<Path Margin="1,1,1,1" Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z" Fill="{DynamicResource BrushTreeViewToggleButtonIconBackground}"/>
						</Border>
					</Border>
				</DataTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="ExpandedStateTemplate">
			<Setter.Value>
				<DataTemplate>
					<Border Width="19" Height="13" Background="Transparent">
						<Border Width="9" Height="9" SnapsToDevicePixels="true" BorderBrush="{DynamicResource BrushTreeViewToggleButtonBorder}" BorderThickness="1" CornerRadius="1" Background="{DynamicResource BrushTreeViewToggleButtonBackground}">
							<Path Margin="1,1,1,1" Data="M 0 2 L 0 3 L 5 3 L 5 2 Z" Fill="{DynamicResource BrushTreeViewToggleButtonIconBackground}"/>
						</Border>
					</Border>
				</DataTemplate>
			</Setter.Value>
		</Setter>

		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Controls:SinacorTreeViewToggleButton}">
					<Grid>
						<ContentPresenter x:Name="PART_CollapsedState" Visibility="Visible" ContentSource="CollapsedState" />
						<ContentPresenter x:Name="PART_ExpandedState" Visibility="Collapsed" ContentSource="ExpandedState" />
						<ContentPresenter x:Name="PART_EmptyState" Visibility="Collapsed" ContentSource="EmptyState" />
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="True">
							<Setter Property="Visibility" Value="Collapsed" TargetName="PART_CollapsedState" />
							<Setter Property="Visibility" Value="Visible" TargetName="PART_ExpandedState" />
							<Setter Property="Visibility" Value="Collapsed" TargetName="PART_EmptyState" />
						</Trigger>
						<Trigger Property="HasItems" Value="False">
							<Setter Property="Visibility" Value="Collapsed" TargetName="PART_CollapsedState" />
							<Setter Property="Visibility" Value="Collapsed" TargetName="PART_ExpandedState" />
							<Setter Property="Visibility" Value="Visible" TargetName="PART_EmptyState" />
							<Setter Property="IsEnabled" Value="False" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type Controls:SinacorTreeViewToggleButton}" BasedOn="{StaticResource PlusMinusTreeViewToggleButton}" />

	<Style x:Key="FolderTreeViewToggleButton" TargetType="{x:Type Controls:SinacorTreeViewToggleButton}" BasedOn="{StaticResource {x:Type Controls:SinacorTreeViewToggleButton}}">
		<Setter Property="CollapsedStateTemplate">
			<Setter.Value>
				<DataTemplate>
					<Rectangle Style="{DynamicResource FolderCollapsedPlus}" />
				</DataTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="ExpandedStateTemplate">
			<Setter.Value>
				<DataTemplate>
					<Rectangle Style="{DynamicResource FolderExpandedMinus}" />
				</DataTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="EmptyStateTemplate">
			<Setter.Value>
				<DataTemplate>
					<Rectangle Style="{DynamicResource FolderDisabled}" />
				</DataTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<!-- END TreeViewToggleButton -->


	<!-- BEGIN TreeView -->
	<Style x:Key="PlusMinusTreeView" TargetType="{x:Type Controls:SinacorTreeView}">
		<Style.Resources>

			<Style TargetType="{x:Type Controls:SinacorTextBlock}" />
			<Style TargetType="{x:Type Controls:SinacorLabel}" />

		</Style.Resources>

		<Setter Property="Border.BorderThickness" Value="1" />
		<Setter Property="Padding" Value="4" />
		<Setter Property="Border.BorderBrush" Value="{DynamicResource BrushTreeViewBorder}" />
		<Setter Property="Panel.Background" Value="{DynamicResource BrushTreeViewBackground}" />
		<Setter Property="ToggleButtonTemplate">
			<Setter.Value>
				<DataTemplate>
					<Controls:SinacorTreeViewToggleButton />
				</DataTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Controls:SinacorTreeView}">
					<Border BorderThickness="{TemplateBinding Border.BorderThickness}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
						<Controls:SinacorScrollViewer Width="Auto" Height="Auto" Focusable="False" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CanContentScroll="False" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" 
                                                      Padding="{TemplateBinding Padding}">
							<ItemsPresenter/>
						</Controls:SinacorScrollViewer>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type Controls:SinacorTreeView}" BasedOn="{StaticResource PlusMinusTreeView}" />
	<!-- END TreeView -->


	<!-- BEGIN TreeViewItem -->
	<Style TargetType="{x:Type Controls:SinacorTreeViewItem}">
		<Setter Property="Background" Value="Transparent"/>

		<Setter Property="ToggleButtonStringFormat" Value="{Binding ToggleButtonStringFormat, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeView}}}" />
		<Setter Property="ToggleButtonTemplate" Value="{Binding ToggleButtonTemplate, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeView}}}" />
		<Setter Property="ToggleButtonTemplateSelector" Value="{Binding ToggleButtonTemplateSelector, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeView}}}" />

		<!--<Setter Property="IconStringFormat" Value="{Binding ToggleButtonStringFormat, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeView}}}" />
        <Setter Property="IconTemplate" Value="{Binding IconTemplate, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeView}}}" />
        <Setter Property="IconTemplateSelector" Value="{Binding IconTemplateSelector, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorTreeView}}}" />-->

		<Setter Property="Template">
			<Setter.Value>

				<ControlTemplate TargetType="{x:Type Controls:SinacorTreeViewItem}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition MinWidth="19" Width="Auto"/>
							<!--<ColumnDefinition Width="Auto"/>-->
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" MinHeight="21" />
							<RowDefinition/>
						</Grid.RowDefinitions>

						<ContentPresenter Grid.Column="0" x:Name="PART_ToggleButton" ContentSource="ToggleButton" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
						<!--<ContentPresenter Grid.Column="1" x:Name="PART_Icon" ContentSource="Icon" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />-->

						<Border x:Name="PART_TreeViewItemContent" SnapsToDevicePixels="true" Grid.Column="1" Padding="1,0" HorizontalAlignment="Left">
							<ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
						</Border>

						<ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.Row="1" Style="{DynamicResource ControlFont}" VerticalAlignment="Top" Margin="0"/>
					</Grid>

					<ControlTemplate.Triggers>
						<Trigger Property="IsExpanded" Value="False">
							<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
						</Trigger>
						<!--<Trigger Property="HasItems" Value="False">
                            <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
                        </Trigger>-->
						<Trigger Property="IsSelected" Value="true">
							<Setter Property="CornerRadius" TargetName="PART_TreeViewItemContent" Value="3"/>
							<Setter Property="Background" Value="{DynamicResource BrushTreeViewItemBackgroundSelected}" TargetName="PART_TreeViewItemContent"/>
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="True"/>
								<Condition Property="IsEnabled" Value="False"/>
							</MultiTrigger.Conditions>
							<Setter Property="Background" Value="{DynamicResource BrushTreeViewItemBackgroundSelectedUnfocused}" TargetName="PART_TreeViewItemContent"/>
						</MultiTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="True"/>
								<Condition Property="IsSelectionActive" Value="False"/>
							</MultiTrigger.Conditions>
							<Setter Property="Background" Value="{DynamicResource BrushTreeViewItemBackgroundSelectedUnfocused}" TargetName="PART_TreeViewItemContent"/>
						</MultiTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="Controls:SinacorDragDrop.IsDragOver" Value="True"/>
							</MultiTrigger.Conditions>
							<Setter Property="Background" Value="{DynamicResource BrushTreeViewItemBackgroundSelectedUnfocused}" TargetName="PART_TreeViewItemContent"/>
						</MultiTrigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<!-- END TreeViewItem -->


	<!-- BEGIN FolderTreeView -->
	<Style x:Key="FolderTreeView" TargetType="{x:Type Controls:SinacorTreeView}" BasedOn="{StaticResource {x:Type Controls:SinacorTreeView}}">
		<Style.Setters>
			<Setter Property="Padding" Value="6,4,4,4" />
			<Setter Property="ToggleButtonTemplate">
				<Setter.Value>
					<DataTemplate>
						<Controls:SinacorTreeViewToggleButton Style="{DynamicResource FolderTreeViewToggleButton}" />
					</DataTemplate>
				</Setter.Value>
			</Setter>
		</Style.Setters>
	</Style>
	<!-- END FolderTreeView -->

	<!--END TREEVIEW-->
</ResourceDictionary>